<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<html>
<head>
    <title>主界面</title>
</head>
<style>
    table {
        font-size: 18px;
        margin: 0 auto;
        text-align: center;
        color: slategray;
    }

    table tr:nth-child(2n) {
        background-color: palegreen;
    }

    h3 {
        text-align: center;
        font-size: 30px;
    }

    #header {
        width: 100%;
        height: 40px;
    }

    #header ul li a {
        padding: 0 20px;
        background-color: aqua;
        color: #ff8040;
        font: bold 20px KaiTi;
        border: 1px solid;
        border-radius: 5px;
        text-decoration: none;
        font-size: 30px;
    }

    #header ul li {
        list-style-type: none;
        float: left;
        margin-left: 10px;
    }

    #footer ul li a {
        padding: 0 35px;
        font: bold 20px KaiTi;
        background-color: aquamarine;
        color: #ff8040;
        border: 1px solid;
        border-radius: 5px;
        text-decoration: none;
        font-size: 35px;
    }

    #footer ul li {
        float: left;
        list-style-type: none;
        padding-bottom: 20px;
        margin-left: 80px;

    }

    #footer {
        position: fixed;
        top: 513px;
    }

    a {
        text-decoration: none;
        color: fuchsia;
    }
    h3{
        color: #23c216;
    }
</style>
</head>

<body class="bg">

<h3>管理员列表</h3>
<div id="header">
</div>
<table border="1" width="100%" cellspacing="0" cellpadding="10">
    <tr>
        <th>序号</th>
        <th>管理员编号</th>
        <th>管理员账号</th>
        <th>管理员密码</th>
        <th>管理员名字</th>
        <th>管理员地址</th>
        <th>管理员生日</th>
        <th colspan="3">操作<a href="add.jsp" style="margin-left: 50px">添加</a></th>
    </tr>

    <c:choose>
        <c:when test="${empty requestScope.list}">
            <tr>
                <td colspan="7">暂无数据</td>
            </tr>
        </c:when>
        <c:otherwise>
            <c:forEach items="${requestScope.list}" var="admin" varStatus="stat">
                <tr>
                    <td>${stat.count}</td>
                    <td>${admin.id}</td>
                    <td>${admin.username}</td>
                    <td>${admin.password}</td>
                    <td>${admin.name}</td>
                    <td>${admin.address}</td>
                    <td>${admin.birthday}</td>
                    <td><a href="#" onclick="delUser(${admin.id})">删除</a></td>
                    <td><a href="/adminServlet?type=findById&id=${admin.id}">修改</a></td>
                    <td><a href="/adminServlet?type=findOne&id=${admin.id}">查看</a></td>
                </tr>
            </c:forEach>
        </c:otherwise>
    </c:choose>

</table>

<div id="footer">
    <ul>
        <li><a href="/adminServlet?type=findAll&currPageNo=1">首页</a></li>
        <li><a href="/adminServlet?type=findAll&currPageNo=${requestScope.pager.currPageNo-1}">上一页</a></li>
        <li><a href="/adminServlet?type=findAll&currPageNo=${requestScope.pager.currPageNo+1}">下一页</a></li>
        <li><a href="/adminServlet?type=findAll&currPageNo=${requestScope.pager.totalPageCount}">末页</a></li>
    </ul>
</div>
<script>
    function delUser(id) {
        //确认框
        var flag = confirm("确定删除?");
        if (flag) {
            //请求下面地址
            location.href = '/adminServlet?type=delAdmin&id=' + id;
        }
    }
</script>
</body>

</html>
